package cn.itwangxiang.android.ui;

import java.util.HashMap;
import java.util.Map;

import cn.itwangxiang.android.R;
import cn.itwangxiang.android.common.HttpUtils;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;

public class DemoHttp extends Activity {
	
	private EditText et1;
	
	private Button bt1;
	
	private WebView wv1;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.demo_http);
		
		initView();
		
		bt1.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String path = et1.getText().toString();
				if(path.indexOf("http://")<0){
					path = "http://"+path;
				}
				wv1.loadUrl(path);
				
				String encode = "utf-8";
				Map<String, String> param = new HashMap<String, String>();
				param.put("", "");
				String result = HttpUtils.sendHttpClientPost(path, param, encode);
				System.out.println(result);
			}
		});
		
	}
	
	public void initView(){
		et1 = (EditText) findViewById(R.id.editText1);
		bt1 = (Button) findViewById(R.id.button1);
		wv1 = (WebView) findViewById(R.id.webView1);
		wv1.loadUrl("http://my.oschina.net/itwangxiang");
	}
}
